<!DOCTYPE HTML>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>if语句</title>
  <script type="text/JavaScript">
var mypen = "black"; //定义变量mypen，存储笔的黑色。
 if(mypen=="black")
{
document.write("笔是黑色的，所以购买");
}
</script>
</head>

<body>
</body>

</html>